import jsonp from '../../src/common/js/jsonp'
import {commonParams, options} from "./config";
import axios from 'axios';

//获取排行榜数据榜单
export function getRanks(){
    const url = '/api/getRanks'  //调用自定义的接口
    const data = Object.assign({},{
       '_': "1581654996937",
       "data": {
            "comm":{"g_tk":5381,"uin":"","format":"json","inCharset":"utf-8","outCharset":"utf-8","notice":0,"platform":"h5","needNewCode":1,"ct":23,"cv":0},
            "topList":{"module":"musicToplist.ToplistInfoServer","method":"GetAll",
            "param":{}}
        }
    })
    return axios.get(url, {
        params: data
    }).then((res) => {
        return Promise.resolve(res.data) //es6新语法，返回一个以给定值解析后的Promise对象
    })
}

// 获取排行榜榜单详情的数据
export function getRanksTopDetail(topId,period){
    const url = '/api/getRankTopDetail'  //调用自定义的接口
    const data = Object.assign({},{
        "-": "getUCGI607299592038584",
        "g_tk": 5381,
        "loginUin": 1337312569,
        "hostUin": 0,
        "format": "json",
        "inCharset": "utf8",
        "outCharset": "utf-8",
        "notice": 0,
        "platform":"yqq.json",
        "needNewCode": 0,
        "data": {"detail":{"module":"musicToplist.ToplistInfoServer","method":"GetDetail","param":{"topId":parseInt(`${topId}`),"offset":0,"num":20,"period":`${period}`}},"comm":{"ct":24,"cv":0}}
    })
    return axios.get(url, {
        params: data
    }).then((res) => {
        return Promise.resolve(res.data) //es6新语法，返回一个以给定值解析后的Promise对象
    })
}
